package cn.ltgodm.template.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.ltgodm.template.user.domain.entity.RoleMenu;
import cn.ltgodm.template.user.service.RoleMenuService;
import cn.ltgodm.template.user.mapper.RoleMenuMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;

/**
* @author wenpeng
* @description 针对表【lt_role_menu(角色和菜单关联表)】的数据库操作Service实现
* @createDate 2024-03-17 22:12:11
*/
@Service
public class RoleMenuServiceImpl extends ServiceImpl<RoleMenuMapper, RoleMenu> implements RoleMenuService{

    @Resource
    private RoleMenuMapper roleMenuMapper;

    /**
     * 根据角色id删除角色和菜单关联表数据
     * @param roleId 角色id
     */
    @Override
    public void removeRoleMenuByRoleId(Long roleId) {
        LambdaQueryWrapper<RoleMenu> lqw = new LambdaQueryWrapper<>();
        lqw.eq(RoleMenu::getRoleId, roleId);
        roleMenuMapper.delete(lqw);
    }

    @Override
    public void removeRoleMenu(Long[] roleIds) {
        LambdaQueryWrapper<RoleMenu> lqw = new LambdaQueryWrapper<>();
        lqw.in(RoleMenu::getRoleId, Arrays.asList(roleIds));
        roleMenuMapper.delete(lqw);
    }
}




